package cn.chenfei.jfx.common;

import javafx.application.Platform;
import javafx.scene.Node;
import javafx.stage.Stage;
import javafx.stage.Window;

public class JFUtils {

    public static void closeCurrentWindow(Object obj) {
        Node node = (Node) obj;
        node.getParent().getScene().getWindow().hide();
    }

    public static void dragCurrentWindow(Object obj) {
        Platform.runLater(() -> {
            Node node = (Node) obj;
            Window window = node.getParent().getScene().getWindow();
            DragUtil.create().move(window, node);
        });
    }

    public static void setIconified(Object obj, boolean flag) {
        Node node = (Node) obj;
        Stage window = (Stage) node.getParent().getScene().getWindow();
        window.setIconified(flag);
    }
}
